﻿/*!	@file	r_draw_vertexbuffer.cpp
	@brief	頂点バッファ
Copyright (c) 2010 Yuya Yamaguchi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "r_draw_vertexbuffer.h"
#include "r_draw_core.h"
#include "r_draw_allocator.h"

// >>>>>>>>>> RTTI >>>>>>>>>>
#include "../rtti/r_rtti_reflection_implement.h"
namespace r{
	namespace draw{
RRTTI_REFLECTION_IMPLEMENT ( r::draw::VertexBuffer, r::rtti::ClassBase )

// <<<<<<<<<< RTTI <<<<<<<<<<

		RALLOC_PLACEMENT_NEW_DELETE_IMPLEMENT( r::draw::VertexBuffer, r::draw::AllocatorData()() )

		VertexBuffer :: VertexBuffer()
			:
			stride ( 0 ),
			numVertex ( 0 )
		{
		}

		VertexBuffer :: VertexBuffer ( r_ui32 _stride, r_ui32 _numVertex )
			:
			stride ( _stride ),
			numVertex ( _numVertex )
		{
		}

		VertexBuffer :: ~VertexBuffer()
		{
		}

		VertexBuffer* VertexBuffer :: create( r_ui32 stride, r_ui32 numVertex )
		{
			Core::instance draw;
			return draw->createVertexBuffer( stride, numVertex );
		}

		void VertexBuffer :: destroy( void )
		{
			if(!this){
				return;
			}
			Core::instance draw;
			draw->destroyVertexBuffer( this );
			delete this;
		}

		r_bool	VertexBuffer :: map()
		{
			return false;
		}
		void	VertexBuffer :: unMap()
		{
		}

		r_ui32	VertexBuffer :: getStride() const
		{
			return stride;
		}

		r_ui32	VertexBuffer :: getNumVertex() const
		{
			return numVertex;
		}

		void*	VertexBuffer :: getBufferAddr()const
		{
			return NULL;
		}
	}
}


